
define(function(require, exports, module) {
    var $=require('zepto');
    sw=require('swiper'),
    api=require('api');
    cn=require('conment');
    module.exports = {
        int:{
            login:sessionStorage.getItem('testKey'),

            _page:'1',
            _length:"10",
            _type:'1',
            _style:'10',
        },
        swiper:function () {
            var swiper = new Swiper('.banner-container', {
                // effect: 'coverflow',
                slidesPerView: 1,
                // spaceBetween: -5,
                pagination: '.swiper-pagination',
                grabCursor: true,
                centeredSlides: true,
            });
        },
        // new
        newBuylist:function () {
            const _this=this;
            cn.Ajax(api.homelist,{
                page:_this.int._page,
                length:_this.int._length,
                type:_this.int._type,
                style:_this.int._style,
            },function(d){
                var water=new Array();

                var list=d.list;
                $('#newBuyList').html('');
                $.each(list,function(i,l,array){
                    // water.push('<li data-code="'+l.code+'"><div class="user-head"><img src="/images/user/usrhead.png" alt=""> </div> <div class="list-txt"> <h4>'+l.nickname+'<i>押金'+l.amountBond+'元</i></h4> ' +
                    //     '<p>通知  搭档市价买入<i>'+l.amount+'元</i>  '+l.name+'</p> </div> </li>')
                    water.push('<li> <div class="new-bulletin-name-img"> </div> <div class="new-bulletin-right"> <div class="new-bulletin-txt-top"> ' +
                        '<span class="name">'+l.nickname+'</span><i class="yajin">押金'+l.amountBond+'元</i><a href="/view/astock_market.html?code='+l.code+'" class="bulle-btn">我也试试</a> </div >' +
                        ' <div class="new-bulletin-txt-bottom">通知搭档市价买入<i class="red">￥'+l.amount+'</i>元 <i class="blur">'+l.name+'</i></div> ' +
                        '</div> </li>')

                });
                $('#newBuyList').append(water.join(''));
                // $('#newBuyList li').on('click',function () {
                //     var code=$(this).data('code');
                //     cn.setItem('market_url',window.location.href)
                //     window.location.href='/view/astock_market.html?code='+code;
                // })

            },'post')
        },
        init:function(){
            const _this=this;
            _this.swiper();
            _this.newBuylist();
            $('#foot_hot_nav .click_login').on('click',function () {
                var href=$(this).data('href');
                if(_this.int.login){
                    window.location.href='/view/'+href+'.html'
                }else{
                    window.location.href='/view/login.html'
                }
            })
            var isModel= window.sessionStorage.getItem('free');
            $('#issueBuy').on('click',function () {
                var href=$(this).data('href');
                if(_this.int.login){
                    window.location.href='/view/'+href+'.html?free=10'
                }else{
                    window.location.href='/view/login.html'
                }
            });
            if(!isModel){
                $('.model_bank').show();
                $('.free_ms').removeClass('fade-leave-active').addClass('fade-enter-active').show()
                window.sessionStorage.setItem('free','true')
            }
            $('#closeModex').on('click',function () {
                $('.model_bank').hide();
                $('.free_ms').removeClass('fade-enter-active').addClass('fade-leave-active').hide(500);
                window.sessionStorage.setItem('free','true')
            });
            $('.free').on('click',function () {
                $('.model_bank').show();
                $('.free_ms').removeClass('fade-leave-active').addClass('fade-enter-active').show()
            })
        },

    }
});